package com.zk.shop.servlet.reply;

import com.zk.shop.service.Impl.ReplyServiceImpl;
import com.zk.shop.service.ReplyService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/DeleteReplyIdServlet")
public class DeleteReplyIdServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ReplyService replyService = new ReplyServiceImpl();
       int replyid = Integer.parseInt(request.getParameter("replyid"));
        int flag = replyService.deleteReply(replyid);
        PrintWriter out=response.getWriter();
        if (flag>0){
            out.print(true);
            System.out.println("删除成功"+flag);
        }else
        {
            System.out.println("删除失败");
        }
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       doPost(req, resp);
    }
}
